//
//  B_MyTopicListVC.m
//  DreamOf
//
//  Created by 薛小刚 on 2018/8/22.
//  Copyright © 2018年 薛小刚. All rights reserved.
//

#import "B_MyTopicListVC.h"
#import "B_TopicListTVC.h"
#import "B_TopicDetailVC.h"

@interface B_MyTopicListVC ()

@property (nonatomic, strong) BaseTableView * mainView;

@end

@implementation B_MyTopicListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"我的话题"];
    self.view = self.mainView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (BaseTableView *)mainView {
    if (!_mainView) {
        WeakSelf(weSelf, self);
        _mainView = [[BaseTableView alloc] init];
        [_mainView setTableViewFrameWithTop:0 left:0 right:0 bottom:0];
        [_mainView.tableView registerNib:[UINib nibWithNibName:@"B_TopicListTVC" bundle:nil] forCellReuseIdentifier:@"B_TopicListTVC"];
        /// 组数
        _mainView.numberOfSectionsBlock = ^NSInteger(UITableView *tableView) {
            return 10;
        };
        /// 组里的个数
        _mainView.numberOfRowsBlock = ^NSInteger(UITableView *tableView, NSInteger section) {
            return 1;
        };
        _mainView.viewForFooterBlock = ^UIView *(UITableView *tableView, NSInteger section) {
            UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
            view.backgroundColor = [UIColor color_main_background_color];
            return view;
        };
        _mainView.viewForHeaderBlock = ^UIView *(UITableView *tableView, NSInteger section) {
            UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
            view.backgroundColor = [UIColor color_main_background_color];
            return view;
        };
        _mainView.heightForFooterBlock = ^CGFloat(UITableView *tableView, NSInteger section) {
            return 0.1;
        };
        _mainView.heightForRowBlock = ^CGFloat(UITableView *tableView, NSIndexPath *indexPath) {
            return 330;
        };
        _mainView.cellForRowBlock = ^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath) {
            ///TODO:在这里取模型赋值
            
            B_TopicListTVC * cell = [tableView dequeueReusableCellWithIdentifier:@"B_TopicListTVC" forIndexPath:indexPath];
            cell.B_userName.text = @"易小川";
            cell.B_topicTitle.text = @"这是一条测试数据";
            cell.B_topicComment.text = @"100";
            cell.B_topicCollection.text = @"1000";
            return cell;
        };
        _mainView.didSelectRow = ^(UITableView *tableView, NSIndexPath *indexPath) {
            
            B_TopicDetailVC * detail = [[B_TopicDetailVC alloc] init];
            //TODO: 在这里需要传话题详情id
            [weSelf pushNextViewController:detail];
            
        };
    }
    return _mainView;
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
